import { request } from "@/utils";

interface ValidCaptcha {
  key: string;
  code: string;
}
export const authApi = {
  // 获取图形验证码
  captcha: () => request.get<Auth.Captcha>("/auth/captcha"),
  // 获取手机验证码
  codeByPhone: (phone: string) => request.get("/auth/phone-code", { phone }),
  // 获取邮箱验证码
  codeByEmail: (email: string) => request.get("/auth/email-code", { email }),
  // 获取邮箱验证码
  validCaptcha: (data: ValidCaptcha) => request.post("/auth/valid-captcha", data),
  // 账号密码登录，获取token
  login: (data: AuthParams.Login) => request.post("/auth/login", data),
  // 退出登录删除token，请使用userStore.logout()
  logout: () => request.post("/auth/logout"),
  // 刷新token，请使用Token.refresh()
  refreshToken: () => request.post("/auth/refresh-token"),
};
